Repository: kubevela/kubevela

Issue:
Workflowsteps cannot access appLabels and  appAnnotations from Context
**Describe the bug**
workflow step definitions cannot access appLabels and  appAnnotations from Context 
An application consuming such a workflow step results in a null pointer error like this:
```
function call error for configMap: cue: marshal error: configMap.$params.value.data.annotation: invalid operand context.appAnnotations (found null, want list or struct) (value: _|_ // configMap.$p │
│ arams.value.data.annotation: invalid operand context.appAnnotations (found null, want list or struct))  
```

**To Reproduce**
1.
Deploy a sample workflow step:

```cue
import (
	"vela/kube"
)

tester: {
	alias: ""
	annotations: {}
	attributes: {}
	description: ""
	labels: {}
	type: "workflow-step"
}

template: {
	opLabel: context.appLabels["testerLabel"]
	testAnnotation: context.appAnnotations["testerAnnotation"]
	configMap: kube.#Apply & {
		$params: {
			value: {
				apiVersion: "v1"
				kind:       "ConfigMap"
				metadata: {
					name:      context.appName + "-tester"
					namespace: context.namespace
				}
				data: {
// uncomment for testing labels
//					label: opLabel  
					annotation: testAnnotation
				}
			}
		}
	}
	parameter: {}
}
```
2. Deploy an application using it
```yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: kubevela-bug
  namespace: default
  labels:
    testerLabel: "hello"
  annotations:
    "testerAnnotation": "world"
spec:
  components: []
  workflow:
    steps:
      - name: tester
        type: tester
```
resulting application
```yaml
Name:         efs-kubevela-poc
Namespace:    default
Labels:       testerLabel=hello
Annotations:  oam.dev/kubevela-version: v1.10.2
              testerAnnotation: world
API Version:  core.oam.dev/v1beta1
Kind:         Application
Metadata:
  Creation Timestamp:  2025-08-20T19:34:27Z
  Finalizers:
    app.oam.dev/resource-tracker-finalizer
  Generation:        1
  Resource Version:  11578
  UID:               cbf8c572-241f-4edb-8cd4-293034ea2a52
Spec:
  Components:
  Workflow:
    Steps:
      Name:  tester
      Type:  tester
Status:
  Conditions:
    Last Transition Time:  2025-08-20T19:34:27Z
    Reason:                Available
    Status:                True
    Type:                  Parsed
    Last Transition Time:  2025-08-20T19:34:27Z
    Reason:                Available
    Status:                True
    Type:                  Revision
    Last Transition Time:  2025-08-20T19:34:27Z
    Reason:                Available
    Status:                True
    Type:                  Policy
    Last Transition Time:  2025-08-20T19:34:27Z
    Reason:                Available
    Status:                True
    Type:                  Render
  Latest Revision:
    Name:               kubevela-bug-v1
    Revision:           1
    Revision Hash:      ad6c027ec0a02e3e
  Observed Generation:  1
  Status:               runningWorkflow
  Workflow:
    App Revision:  kubevela-bug-v1
    Context Backend:
      API Version:  v1
      Kind:         ConfigMap
      Name:         workflow-kubevela-bug-context
      Namespace:    default
      UID:          73381bb1-0176-43d6-9d09-a46a8090c07f
    Finished:       false
    Mode:           StepByStep-DAG
    Start Time:     2025-08-20T19:34:27Z
    Status:         executing
    Steps:
      First Execute Time:  2025-08-20T19:34:27Z
      Id:                  akodiarofq
      Last Execute Time:   2025-08-20T19:34:32Z
      Message:             function call error for configMap: cue: marshal error: configMap.$params.value.data.annotation: invalid operand context.appAnnotations (found null, want list or struct) (value: _|_ // configMap.$params.value.data.annotation: invalid operand context.appAnnotations (found null, want list or struct))
      Name:                tester
      Phase:               failed
      Reason:              Execute
      Type:                tester
    Suspend:               false
    Terminated:            false
Events:
  Type    Reason           Age              From         Message
  ----    ------           ----             ----         -------
  Normal  Parsed           0s (x6 over 5s)  Application  Parsed successfully
  Normal  Revisioned       0s (x6 over 5s)  Application  Revisioned successfully
  Normal  PolicyGenerated  0s (x6 over 5s)  Application  Policy generated successfully
  Normal  Rendered         0s (x6 over 5s)  Application  Rendered successfully
```

**Expected behavior**
Application should reconcile successfully 



**KubeVela Version**

CLI Version: 1.10.2
Core Version: 1.10.2
GitRevision: 424e433963551eac070b4369829c4c674fce7ff1
GolangVersion: go1.24.0


**Cluster information**
k3d: v1.27.4+k3s1



Hints from issue comments:

Solution patch:
diff --git a/app.yaml b/app.yaml
deleted file mode 100644
index e69de29b..00000000
diff --git a/pkg/controller/core.oam.dev/v1beta1/application/generator.go b/pkg/controller/core.oam.dev/v1beta1/application/generator.go
index ce742ac1..138d5dc5 100644
--- a/pkg/controller/core.oam.dev/v1beta1/application/generator.go
+++ b/pkg/controller/core.oam.dev/v1beta1/application/generator.go
@@ -508,6 +508,7 @@ func getComponentResources(ctx context.Context, manifest *types.ComponentManifes
 	return workload, traits, nil
 }
 
+// generateContextDataFromApp builds the process context for workflow (non-component) execution.
 func generateContextDataFromApp(app *v1beta1.Application, appRev string) velaprocess.ContextData {
 	data := velaprocess.ContextData{
 		Namespace:       app.Namespace,
@@ -519,5 +520,12 @@ func generateContextDataFromApp(app *v1beta1.Application, appRev string) velapro
 		data.WorkflowName = app.Annotations[oam.AnnotationWorkflowName]
 		data.PublishVersion = app.Annotations[oam.AnnotationPublishVersion]
 	}
+	// pass labels and annotations to workflow context
+	if len(app.Labels) > 0 {
+		data.AppLabels = app.Labels
+	}
+	if len(app.Annotations) > 0 {
+		data.AppAnnotations = app.Annotations
+	}
 	return data
 }



Test patch:
diff --git a/pkg/controller/core.oam.dev/v1beta1/application/generator_test.go b/pkg/controller/core.oam.dev/v1beta1/application/generator_test.go
index 06a38a85..7314c6dc 100644
--- a/pkg/controller/core.oam.dev/v1beta1/application/generator_test.go
+++ b/pkg/controller/core.oam.dev/v1beta1/application/generator_test.go
@@ -289,4 +289,31 @@ var _ = Describe("Test Application workflow generator", func() {
 		_, _, err = handler.GenerateApplicationSteps(logCtx, app, appParser, af)
 		Expect(err).NotTo(BeNil())
 	})
+
+	It("Test workflow context contains app labels and annotations", func() {
+		app := &oamcore.Application{
+			TypeMeta: metav1.TypeMeta{Kind: "Application", APIVersion: "core.oam.dev/v1beta1"},
+			ObjectMeta: metav1.ObjectMeta{
+				Name:        "app-with-meta",
+				Namespace:   namespaceName,
+				Labels:      map[string]string{"team": "platform", "env": "prod"},
+				Annotations: map[string]string{"description": "meta test", "owner": "sre"},
+			},
+			Spec: oamcore.ApplicationSpec{Components: []common.ApplicationComponent{}},
+		}
+		ctxData := generateContextDataFromApp(app, "apprev-with-meta")
+		Expect(ctxData.AppLabels).To(Equal(app.Labels))
+		Expect(ctxData.AppAnnotations).To(Equal(app.Annotations))
+	})
+
+	It("Test workflow context empty labels annotations", func() {
+		app := &oamcore.Application{
+			TypeMeta:   metav1.TypeMeta{Kind: "Application", APIVersion: "core.oam.dev/v1beta1"},
+			ObjectMeta: metav1.ObjectMeta{Name: "app-without-meta", Namespace: namespaceName},
+			Spec:       oamcore.ApplicationSpec{Components: []common.ApplicationComponent{}},
+		}
+		ctxData := generateContextDataFromApp(app, "apprev-without-meta")
+		Expect(ctxData.AppLabels).To(BeNil())
+		Expect(ctxData.AppAnnotations).To(BeNil())
+	})
 })